import reducers from '@/app/reducers';
import {context,IO} from "@/app/io";

//配置接口参数

context.create('Demo',{
    getList:{
        mockUrl:'../../mock/home/test.json'
    }
});
const demoModel={
    reducer:(defauleState = {
        demoInfo:{}
    },action)=>{
        switch (action.type) {
            case 'demo_info': {
                return Object.assign({},defauleState,{
                    demoInfo:action.res
                });
            }
        }
        return defauleState;
    },
    action:(dispatch)=>{
         return {
             getList:()=>{
                 console.log("action.getList");
                 IO.Demo.getList().then((res)=>{
                     console.log("action.getList.response");
                     dispatch({
                         type:"demo_info",
                         res
                     });
                 }).catch();
             }
         };
    }
};

reducers.assemble= {demoReducer:demoModel.reducer};

const action=demoModel.action;
export {
    action,
    IO
};